home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / Symbol.Z / Symbol
Encoding:
Text File  |  1998-10-28  |  3.0 KB  |  133 lines

  1.  
  2.  
  3.  
  4.      SSSSyyyymmmmbbbboooollll((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         SSSSyyyymmmmbbbboooollll((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       Symbol - manipulate Perl symbols and their names
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           use Symbol;
  13.  
  14.           $sym = gensym;
  15.           open($sym, "filename");
  16.           $_ = <$sym>;
  17.           #    etc.
  18.  
  19.           ungensym $sym;      # no effect
  20.  
  21.           print qualify("x"), "\n";             # "Test::x"
  22.           print qualify("x", "FOO"), "\n"         # "FOO::x"
  23.           print qualify("BAR::x"), "\n";         # "BAR::x"
  24.           print qualify("BAR::x", "FOO"), "\n";  # "BAR::x"
  25.           print qualify("STDOUT", "FOO"), "\n";  # "main::STDOUT" (global)
  26.           print qualify(\*x), "\n";             # returns \*x
  27.           print qualify(\*x, "FOO"), "\n";         # returns \*x
  28.  
  29.           use strict refs;
  30.           print { qualify_to_ref $fh } "foo!\n";
  31.           $ref = qualify_to_ref $name, $pkg;
  32.  
  33.           use Symbol qw(delete_package);
  34.           delete_package('Foo::Bar');
  35.           print "deleted\n"    unless exists $Foo::{'Bar::'};
  36.  
  37.  
  38.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  39.       Symbol::gensym creates an anonymous glob and returns a
  40.       reference to it.  Such a glob    reference can be used as a
  41.       file or directory handle.
  42.  
  43.       For backward compatibility with older    implementations    that
  44.       didn't support anonymous globs, Symbol::ungensym is also
  45.       provided.  But it doesn't do anything.
  46.  
  47.       Symbol::qualify turns    unqualified symbol names into
  48.       qualified variable names (e.g. "myvar" ->
  49.       "MyPackage::myvar").    If it is given a second    parameter,
  50.       qualify uses it as the default package; otherwise, it    uses
  51.       the package of its caller.  Regardless, global variable
  52.       names    (e.g. "STDOUT",    "ENV", "SIG") are always qualfied with
  53.       "main::".
  54.  
  55.       Qualification    applies    only to    symbol names (strings).
  56.       References are left unchanged    under the assumption that they
  57.       are glob references, which are qualified by their nature.
  58.  
  59.       Symbol::qualify_to_ref is just like Symbol::qualify except
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      SSSSyyyymmmmbbbboooollll((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         SSSSyyyymmmmbbbboooollll((((3333))))
  71.  
  72.  
  73.  
  74.       that it returns a glob ref rather than a symbol name,    so you
  75.       can use the result even if use strict    'refs' is in effect.
  76.  
  77.       Symbol::delete_package wipes out a whole package namespace.
  78.       Note this routine is not exported by default--you may    want
  79.       to import it explicitly.
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.